/**
 */
package fUML.Semantics.Actions.BasicActions;

import fUML.Semantics.Activities.IntermediateActivities.ActivityNodeActivation;

import fUML.Semantics.Classes.Kernel.BooleanValue;
import fUML.Semantics.Classes.Kernel.Link;
import fUML.Semantics.Classes.Kernel.Value;

import fUML.Syntax.Actions.BasicActions.InputPin;
import fUML.Syntax.Actions.BasicActions.OutputPin;
import fUML.Syntax.Actions.BasicActions.Pin;

import org.eclipse.emf.common.util.EList;

/**
 * <!-- begin-user-doc -->
 * A representation of the model object '<em><b>Action Activation</b></em>'.
 * <!-- end-user-doc -->
 *
 * <!-- begin-model-doc -->
 * An action activation is an activity node activation for a node that is an
 *                 action.
 * <!-- end-model-doc -->
 *
 * <p>
 * The following features are supported:
 * <ul>
 *   <li>{@link fUML.Semantics.Actions.BasicActions.ActionActivation#getPinActivations <em>Pin Activations</em>}</li>
 *   <li>{@link fUML.Semantics.Actions.BasicActions.ActionActivation#isFiring <em>Firing</em>}</li>
 * </ul>
 * </p>
 *
 * @see fUML.Semantics.Actions.BasicActions.BasicActionsPackage#getActionActivation()
 * @model abstract="true"
 * @generated
 */
public interface ActionActivation extends ActivityNodeActivation {
	/**
	 * Returns the value of the '<em><b>Pin Activations</b></em>' reference list.
	 * The list contents are of type {@link fUML.Semantics.Actions.BasicActions.PinActivation}.
	 * It is bidirectional and its opposite is '{@link fUML.Semantics.Actions.BasicActions.PinActivation#getActionActivation <em>Action Activation</em>}'.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * <!-- begin-model-doc -->
	 * The activations of the pins owned by the action of this action
	 *                 activation.
	 * <!-- end-model-doc -->
	 * @return the value of the '<em>Pin Activations</em>' reference list.
	 * @see fUML.Semantics.Actions.BasicActions.BasicActionsPackage#getActionActivation_PinActivations()
	 * @see fUML.Semantics.Actions.BasicActions.PinActivation#getActionActivation
	 * @model opposite="actionActivation" ordered="false"
	 * @generated
	 */
	EList<PinActivation> getPinActivations();

	/**
	 * Returns the value of the '<em><b>Firing</b></em>' attribute.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * <!-- begin-model-doc -->
	 * Whether this action activation is already firing. This attribute is only used
	 *                   if the action for this action activation has isLocallyReentrant = false (the
	 *                   default). If isLocallyReentrant=true, then firing always just remains
	 *                 false.
	 * <!-- end-model-doc -->
	 * @return the value of the '<em>Firing</em>' attribute.
	 * @see #setFiring(boolean)
	 * @see fUML.Semantics.Actions.BasicActions.BasicActionsPackage#getActionActivation_Firing()
	 * @model required="true" ordered="false"
	 * @generated
	 */
	boolean isFiring();

	/**
	 * Sets the value of the '{@link fUML.Semantics.Actions.BasicActions.ActionActivation#isFiring <em>Firing</em>}' attribute.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @param value the new value of the '<em>Firing</em>' attribute.
	 * @see #isFiring()
	 * @generated
	 */
	void setFiring(boolean value);

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @model required="true" ordered="false"
	 * @generated
	 */
	boolean fUML_isFiring();

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * <!-- begin-model-doc -->
	 * Do the required action behavior.
	 *  
	 * <!-- end-model-doc -->
	 * @model
	 * @generated
	 */
	void doAction();

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * <!-- begin-model-doc -->
	 * // Fire all output pins and send offers on all outgoing control
	 *                   flows.
	 *  
	 *  Action action = (Action)(this.node);
	 *  
	 *                   // *** Send offers from all output pins concurrently. ***
	 *  OutputPinList
	 *                   outputPins = action.output;
	 *  for (Iterator i = outputPins.iterator();
	 *                   i.hasNext();) {
	 *  OutputPin outputPin = (OutputPin)i.next();
	 *                   PinActivation pinActivation = this.getPinActivation(outputPin);
	 *                   pinActivation.sendUnofferedTokens();
	 *  }
	 *  
	 *  // Send offers
	 *                   on all outgoing control flows.
	 *  if (this.outgoingEdges.size() > 0)
	 *                   {
	 *  TokenList tokens = new TokenList();
	 *  tokens.addValue(new
	 *                   ControlToken());
	 *  this.addTokens(tokens);
	 *                   this.outgoingEdges.getValue(0).sendOffer(tokens);
	 *  }
	 *  
	 * <!-- end-model-doc -->
	 * @model
	 * @generated
	 */
	void sendOffers();

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * <!-- begin-model-doc -->
	 * // Add a pin activation to this action activation.
	 *  
	 *                   this.pinActivations.addValue(pinActivation);
	 *                   pinActivation.actionActivation = this;
	 *  
	 * <!-- end-model-doc -->
	 * @model pinActivationRequired="true" pinActivationOrdered="false"
	 * @generated
	 */
	void addPinActivation(PinActivation pinActivation);

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * <!-- begin-model-doc -->
	 * // Precondition: The given pin is owned by the action of the action
	 *                   activation.
	 *  // Return the pin activation corresponding to the given
	 *                   pin.
	 *  
	 *  PinActivation pinActivation = null;
	 *  int i =
	 *                   1;
	 *  while (pinActivation == null & i <=
	 *                   this.pinActivations.size()) {
	 *  PinActivation thisPinActivation =
	 *                   this.pinActivations.getValue(i-1);
	 *  if (thisPinActivation.node == pin)
	 *                   {
	 *  pinActivation = thisPinActivation;
	 *  }
	 *  i = i +
	 *                   1;
	 *  }
	 *  
	 *  return pinActivation;
	 *  
	 *  
	 * <!-- end-model-doc -->
	 * @model required="true" ordered="false" pinRequired="true" pinOrdered="false"
	 * @generated
	 */
	PinActivation getPinActivation(Pin pin);

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @model pinRequired="true" pinOrdered="false" valueRequired="true" valueOrdered="false"
	 * @generated
	 */
	void putToken(OutputPin pin, Value value);

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * <!-- begin-model-doc -->
	 * // Precondition: The action execution has fired and the given pin is owned by
	 *                   the action of the action execution.
	 *  // Place tokens for the given values
	 *                   on the pin activation corresponding to the given output pin.
	 *  
	 *  //
	 *                   Debug.println("[putTokens] node = " + this.node.name);
	 *  
	 *  for (int
	 *                   i = 0; i < values.size(); i++) {
	 *  Value value =
	 *                   values.getValue(i);
	 *  this.putToken(pin, value);
	 *  }
	 *                   
	 *  
	 * <!-- end-model-doc -->
	 * @model pinRequired="true" pinOrdered="false" valuesMany="true" valuesOrdered="false"
	 * @generated
	 */
	void putTokens(OutputPin pin, EList<Value> values);

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @model ordered="false" pinRequired="true" pinOrdered="false"
	 * @generated
	 */
	EList<Value> getTokens(InputPin pin);

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * <!-- begin-model-doc -->
	 * // Precondition: The action execution has fired and the given pin is owned by
	 *                   the action of the action execution.
	 *  // Take any tokens held by the pin
	 *                   activation corresponding to the given input pin and return them.
	 *                   
	 *  Debug.println("[takeTokens] node = " + this.node.name + ", pin = " +
	 *                   pin.name);
	 *  
	 *  PinActivation pinActivation =
	 *                   this.getPinActivation(pin);
	 *  TokenList tokens =
	 *                   pinActivation.takeUnofferedTokens();
	 *  
	 *  ValueList values = new
	 *                   ValueList();
	 *  for (int i = 0; i < tokens.size(); i++) {
	 *                   Token token = tokens.getValue(i);
	 *  Value value =
	 *                   ((ObjectToken)token).value;
	 *  if (value != null) {
	 *                   values.addValue(value);
	 *  }
	 *  }
	 *  
	 *  return
	 *                   values;
	 *  
	 * <!-- end-model-doc -->
	 * @model ordered="false" pinRequired="true" pinOrdered="false"
	 * @generated
	 */
	EList<Value> takeTokens(InputPin pin);

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * <!-- begin-model-doc -->
	 * // Test if the given value participates in the given link.
	 *  
	 *                   FeatureValueList linkFeatureValues = link.getFeatureValues();
	 *  
	 *                   boolean participates = false;
	 *  int i = 1;
	 *  while (!participates
	 *                   & i <= linkFeatureValues.size()) {
	 *  participates =
	 *                   linkFeatureValues.getValue(i-1).values.getValue(0).equals(value);
	 *  i = i +
	 *                   1;
	 *  }
	 *  
	 *  return participates;
	 *  
	 * <!-- end-model-doc -->
	 * @model required="true" ordered="false" valueRequired="true" valueOrdered="false" linkRequired="true" linkOrdered="false"
	 * @generated
	 */
	boolean valueParticipatesInLink(Value value, Link link);

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * <!-- begin-model-doc -->
	 * // Make a Boolean value using the built-in Boolean primitive type.
	 *  //
	 *                   [This ensures that Boolean values created internally are the same as the default
	 *                   used for evaluating Boolean literals.]
	 *  
	 *  LiteralBoolean
	 *                   booleanLiteral = new LiteralBoolean();
	 *  booleanLiteral.value =
	 *                   value;
	 *  return
	 *                   (BooleanValue)(this.getExecutionLocus().executor.evaluate(booleanLiteral));
	 *                 
	 * <!-- end-model-doc -->
	 * @model required="true" ordered="false" valueRequired="true" valueOrdered="false"
	 * @generated
	 */
	BooleanValue makeBooleanValue(boolean value);

} // ActionActivation
